# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Guillaume Horel <guillaume.horel@gmail.com>

_pkg=orc
pkgname=apache-${_pkg}
pkgver=1.9.0
pkgrel=5
pkgdesc="Columnar storage for Hadoop workloads."
arch=(loong64 x86_64)
url="https://orc.apache.org"
license=(Apache)
depends=(lz4 protobuf snappy zlib zstd)
makedepends=(cmake)
makedepends+=(gtest)
source=(https://dlcdn.apache.org/${_pkg}/${_pkg}-${pkgver}/${_pkg}-${pkgver}.tar.gz{,.asc})
sha256sums=('0dca8bbccdb2ee87e59ba964933436beebd02ea78c4134424828a8127fbc4faa'
            'SKIP')
validpgpkeys=(F28C9C925C188C35E345614DEDA00CE834F0FC5C) # Dongjoon Hyun (CODE SIGNING KEY) <dongjoon@apache.org>

prepare(){
  cd ${_pkg}-${pkgver}
  sed -i 's/orc STATIC/orc SHARED/' c++/src/CMakeLists.txt
}

build(){
  cmake -B build -S ${_pkg}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="/usr" \
    -DSTOP_BUILD_ON_WARNING=OFF \
    -DLZ4_HOME="/usr" \
    -DPROTOBUF_HOME="/usr" \
    -DSNAPPY_HOME="/usr" \
    -DZLIB_HOME="/usr" \
    -DZSTD_HOME="/usr" \
    -DGTEST_HOME="/usr" \
    -DORC_PREFER_STATIC_PROTOBUF=OFF \
    -DORC_PREFER_STATIC_SNAPPY=OFF \
    -DORC_PREFER_STATIC_LZ4=OFF \
    -DORC_PREFER_STATIC_ZSTD=OFF \
    -DORC_PREFER_STATIC_ZLIB=OFF \
    -DBUILD_LIBHDFSPP=OFF \
    -DBUILD_JAVA=OFF \
    -DSTOP_BUILD_ON_WARNING=OFF \
    -DINSTALL_VENDORED_LIBS=OFF \
    -DBUILD_CPP_TESTS=OFF
  make -C build
}

check(){
  # Some tests failures https://github.com/apache/orc/issues/1068
  make -C build test-out || echo "Warning: Tests failed"
}

package(){
  make DESTDIR="${pkgdir}" -C build install
}
